package com.yinhai.uid.config;

import com.yinhai.uid.zookeeper.ZookeeperProperties;
import com.yinhai.uid.zookeeper.ZookeeperRegistryCenter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author taojie
 * @Date: 2018/12/29 15:59
 * @Description:
 */
@Configuration
public class ZookeeperRegistryCenterConfiguration {

	@Autowired
	private ZookeeperProperties zookeeperProperties;

	/**
	 * 初始化Zookeeper注册中心
	 * @param
	 * @return
	 */
	@Bean(initMethod = "init")
	@ConditionalOnProperty(name="uid.implementation",havingValue = "zookeeper")
	public ZookeeperRegistryCenter zookeeperRegistryCenter() {
		return new ZookeeperRegistryCenter(zookeeperProperties);
	}

}
